home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / dcu.bst < prev    next >
Text File  |  1994-07-31  |  26KB  |  1,366 lines

  1. % BibTeX standard bibliography style `dcu' (one of the harvard family)
  2.     % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09.
  3.     % Copyright (C) 1991, all rights reserved.
  4.     % Copying of this file is authorized only if either
  5.     % (1) you make absolutely no changes to your copy, including name, or
  6.     % (2) if you do make changes, you name it something other than
  7.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, abbrv.bst, agsm.bst,
  8.         % dcu.bst or kluwer.bst.
  9.     % This restriction helps ensure that all standard styles are identical.
  10.     % The file harvard.tex has the documentation for this style.
  11.  
  12. % ACKNOWLEDGEMENT:
  13. %   This document is a modified version of alpha.bst to which it owes much of
  14. %   its functionality.
  15.  
  16. % AUTHOR
  17. %   Peter Williams, Key Centre for Design Quality, Sydney University
  18. %   e-mail: peterw@archsci.arch.su.oz.au
  19.  
  20. ENTRY
  21.   { address
  22.     author
  23.     booktitle
  24.     chapter
  25.     edition
  26.     editor
  27.     howpublished
  28.     institution
  29.     journal
  30.     key
  31.     month
  32.     note
  33.     number
  34.     organization
  35.     pages
  36.     publisher
  37.     school
  38.     series
  39.     title
  40.     type
  41.     URL
  42.     volume
  43.     year
  44.   }
  45.   { field.used etal.allowed etal.required }
  46.   { extra.label sort.label list.year }
  47.  
  48. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  49.  
  50. FUNCTION {init.state.consts}
  51. { #0 'before.all :=
  52.   #1 'mid.sentence :=
  53.   #2 'after.sentence :=
  54.   #3 'after.block :=
  55. }
  56.  
  57. STRINGS { s t f }
  58.  
  59. FUNCTION {output.nonnull}
  60. { 's :=
  61.   output.state mid.sentence =
  62.     { ", " * write$ }
  63.     { output.state after.block =
  64.     { add.period$ write$
  65.       newline$
  66.       "\newblock " write$
  67.     }
  68.     { output.state before.all =
  69.         'write$
  70.         { add.period$ " " * write$ }
  71.       if$
  72.     }
  73.       if$
  74.       mid.sentence 'output.state :=
  75.     }
  76.   if$
  77.   s
  78. }
  79.  
  80. FUNCTION {output}
  81. { duplicate$ empty$
  82.     'pop$
  83.     'output.nonnull
  84.   if$
  85. }
  86.  
  87. FUNCTION {output.check}
  88. { 't :=
  89.   duplicate$ empty$
  90.     { pop$ "empty " t * " in " * cite$ * warning$ }
  91.     'output.nonnull
  92.   if$
  93. }
  94.  
  95. FUNCTION {item.check}
  96. { 't :=
  97.   empty$
  98.     { "empty " t * " in " * cite$ * warning$ }
  99.     { skip$ }
  100.   if$
  101. }
  102.  
  103. FUNCTION {fin.entry}
  104. { add.period$
  105.   write$
  106.   newline$
  107. }
  108.  
  109. FUNCTION {new.block}
  110. { output.state before.all =
  111.     'skip$
  112.     { after.block 'output.state := }
  113.   if$
  114. }
  115.  
  116. FUNCTION {not}
  117. {   { #0 }
  118.     { #1 }
  119.   if$
  120. }
  121.  
  122. FUNCTION {and}
  123. {   'skip$
  124.     { pop$ #0 }
  125.   if$
  126. }
  127.  
  128. FUNCTION {or}
  129. {   { pop$ #1 }
  130.     'skip$
  131.   if$
  132. }
  133.  
  134. FUNCTION {field.or.null}
  135. { duplicate$ empty$
  136.     { pop$ "" }
  137.     'skip$
  138.   if$
  139. }
  140.  
  141. FUNCTION {emphasize}
  142. { duplicate$ empty$
  143.     { pop$ "" }
  144.     { "{\em " swap$ * "}" * }
  145.   if$
  146. }
  147.  
  148. FUNCTION {embolden}
  149. { duplicate$ empty$
  150.     { pop$ "" }
  151.     { "{\bf " swap$ * "}" * }
  152.   if$
  153. }
  154.  
  155. FUNCTION {quote}
  156. { duplicate$ empty$
  157.     { pop$ "" }
  158.     { "`" swap$ * "'" * }
  159.   if$
  160. }
  161.  
  162. FUNCTION {write.url}
  163. { URL empty$
  164.     { skip$ }
  165.     { "\newline\harvardurl{" URL * "}" * write$ newline$ }
  166.   if$
  167. }
  168.  
  169. INTEGERS { nameptr namesleft numnames }
  170.  
  171. FUNCTION {format.names}
  172. { 's :=
  173.   'f :=
  174.   #1 'nameptr :=
  175.   s num.names$ 'numnames :=
  176.   numnames 'namesleft :=
  177.     { namesleft #0 > }
  178.     { s nameptr f format.name$ 't :=
  179.       nameptr #1 >
  180.     { namesleft #1 >
  181.         { ", " * t * }
  182.         { t "others" =
  183.         { " et~al." * }
  184.         { " \harvardand\ " * t * }
  185.           if$
  186.         }
  187.       if$
  188.     }
  189.     't
  190.       if$
  191.       nameptr #1 + 'nameptr :=
  192.       namesleft #1 - 'namesleft :=
  193.     }
  194.   while$
  195. }
  196.  
  197. FUNCTION {format.authors}
  198. { author empty$
  199.     { "" }
  200.     { "{vv~}{ll}{, jj}{, f.}" author format.names }
  201.   if$
  202. }
  203.  
  204. FUNCTION {format.editors}
  205. { editor empty$
  206.     { "" }
  207.     { "{vv~}{ll}{, jj}{, f.}" editor format.names
  208.       editor num.names$ #1 >
  209.     { " (eds)" * }
  210.     { " (ed.)" * }
  211.       if$
  212.     }
  213.   if$
  214. }
  215.  
  216. FUNCTION {format.editors.reverse}
  217. { editor empty$
  218.     { "" }
  219.     { "{f.~}{vv~}{ll}{, jj}" editor format.names
  220.       editor num.names$ #1 >
  221.     { " (eds)" * }
  222.     { " (ed.)" * }
  223.       if$
  224.     }
  225.   if$
  226. }
  227.  
  228. FUNCTION {format.title}
  229. { title empty$
  230.     { "" }
  231.     { title "t" change.case$ }
  232.   if$
  233. }
  234.  
  235. FUNCTION {n.dashify}
  236. { 't :=
  237.   ""
  238.     { t empty$ not }
  239.     { t #1 #1 substring$ "-" =
  240.     { t #1 #2 substring$ "--" = not
  241.         { "--" *
  242.           t #2 global.max$ substring$ 't :=
  243.         }
  244.         {   { t #1 #1 substring$ "-" = }
  245.         { "-" *
  246.           t #2 global.max$ substring$ 't :=
  247.         }
  248.           while$
  249.         }
  250.       if$
  251.     }
  252.     { t #1 #1 substring$ *
  253.       t #2 global.max$ substring$ 't :=
  254.     }
  255.       if$
  256.     }
  257.   while$
  258. }
  259.  
  260. FUNCTION {format.btitle}
  261. { title emphasize
  262. }
  263.  
  264. FUNCTION {tie.or.space.connect}
  265. { duplicate$ text.length$ #3 <
  266.     { "~" }
  267.     { " " }
  268.   if$
  269.   swap$ * *
  270. }
  271.  
  272. FUNCTION {either.or.check}
  273. { empty$
  274.     'pop$
  275.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  276.   if$
  277. }
  278.  
  279. FUNCTION {format.bvolume}
  280. { volume empty$
  281.     { "" }
  282.     { "Vol." volume tie.or.space.connect
  283.       series empty$
  284.     'skip$
  285.     { " of " * series emphasize * }
  286.       if$
  287.       "volume and number" number either.or.check
  288.     }
  289.   if$
  290. }
  291.  
  292. FUNCTION {format.number.series}
  293. { volume empty$
  294.     { number empty$
  295.     { series field.or.null }
  296.     { output.state mid.sentence =
  297.         { "number" }
  298.         { "Number" }
  299.       if$
  300.       number tie.or.space.connect
  301.       series empty$
  302.         { "there's a number but no series in " cite$ * warning$ }
  303.         { " in " * series emphasize * }
  304.       if$
  305.     }
  306.       if$
  307.     }
  308.     { "" }
  309.   if$
  310. }
  311.  
  312. FUNCTION {format.edition}
  313. { edition empty$
  314.     { "" }
  315.     { output.state mid.sentence =
  316.     { edition "l" change.case$ " edn" * }
  317.     { edition "t" change.case$ " edn" * }
  318.       if$
  319.     }
  320.   if$
  321. }
  322.  
  323. INTEGERS { multiresult }
  324.  
  325. FUNCTION {multi.page.check}
  326. { 't :=
  327.   #0 'multiresult :=
  328.     { multiresult not
  329.       t empty$ not
  330.       and
  331.     }
  332.     { t #1 #1 substring$
  333.       duplicate$ "-" =
  334.       swap$ duplicate$ "," =
  335.       swap$ "+" =
  336.       or or
  337.     { #1 'multiresult := }
  338.     { t #2 global.max$ substring$ 't := }
  339.       if$
  340.     }
  341.   while$
  342.   multiresult
  343. }
  344.  
  345. FUNCTION {format.pages}
  346. { pages empty$
  347.     { "" }
  348.     { pages multi.page.check
  349.     { "pp.~" pages n.dashify * }
  350.     { "p.~" pages * }
  351.       if$
  352.     }
  353.   if$
  354. }
  355.  
  356. FUNCTION {format.vol.num.pages}
  357. { volume embolden field.or.null
  358.   number empty$
  359.     'skip$
  360.     { "(" number * ")" * *
  361.       volume empty$
  362.     { "there's a number but no volume in " cite$ * warning$ }
  363.     'skip$
  364.       if$
  365.     }
  366.   if$
  367.   pages empty$
  368.     'skip$
  369.     { duplicate$ empty$
  370.     { pop$ format.pages }
  371.     { ":~" * pages n.dashify * }
  372.       if$
  373.     }
  374.   if$
  375. }
  376.  
  377. FUNCTION {format.chapter.pages}
  378. { chapter empty$
  379.     'format.pages
  380.     { type empty$
  381.     { "chapter" }
  382.     { type "l" change.case$ }
  383.       if$
  384.       chapter tie.or.space.connect
  385.       pages empty$
  386.     'skip$
  387.     { ", " * format.pages * }
  388.       if$
  389.     }
  390.   if$
  391. }
  392.  
  393. FUNCTION {format.in.ed.booktitle}
  394. { booktitle empty$
  395.     { "" }
  396.     { editor empty$
  397.     { booktitle emphasize }
  398.     { "{\em in} " format.editors.reverse * ", " * booktitle emphasize * }
  399.       if$
  400.     }
  401.   if$
  402. }
  403.  
  404. FUNCTION {empty.misc.check}
  405. { author empty$ title empty$ howpublished empty$
  406.   month empty$ year empty$ note empty$
  407.   and and and and and
  408.   key empty$ not and
  409.     { "all relevant fields are empty in " cite$ * warning$ }
  410.     'skip$
  411.   if$
  412. }
  413.  
  414. FUNCTION {format.thesis.type}
  415. { type empty$
  416.     'skip$
  417.     { pop$
  418.       type "t" change.case$
  419.     }
  420.   if$
  421. }
  422.  
  423. FUNCTION {format.tr.number}
  424. { type empty$
  425.     { "Technical Report" }
  426.     'type
  427.   if$
  428.   number empty$
  429.     { "t" change.case$ }
  430.     { number tie.or.space.connect }
  431.   if$
  432. }
  433.  
  434. FUNCTION {format.article.crossref}
  435. { key empty$
  436.     { journal empty$
  437.     { "need key or journal for " cite$ * " to crossref " * crossref *
  438.       warning$
  439.       ""
  440.     }
  441.     { "in {\em " journal * "\/}" * " \cite{" * crossref * "}" *
  442.         }
  443.       if$
  444.     }
  445.     { " {\em in} \citeasnoun{" crossref * "}" * }
  446.   if$
  447. }
  448.  
  449. FUNCTION {format.book.crossref}
  450. { volume empty$
  451.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  452.       "in "
  453.     }
  454.     { "Vol." volume tie.or.space.connect
  455.       " of " *
  456.     }
  457.   if$
  458.   editor empty$
  459.   editor field.or.null author field.or.null =
  460.   or
  461.     { key empty$
  462.     { series empty$
  463.         { "need editor, key, or series for " cite$ * " to crossref " *
  464.           crossref * warning$
  465.           "" *
  466.         }
  467.         { "{\em " * series * "\/}" * " \cite{" * crossref * "}" *}
  468.       if$
  469.     }
  470.     { " \citeasnoun{" * crossref * "}" * }
  471.       if$
  472.     }
  473.     { " \citeasnoun{" * crossref * "}" * }
  474.   if$
  475. }
  476.  
  477. FUNCTION {format.incoll.inproc.crossref}
  478. { editor empty$
  479.   editor field.or.null author field.or.null =
  480.   or
  481.     {
  482.       key empty$
  483.     { booktitle empty$
  484.         { "need editor, key, or booktitle for " cite$ * " to crossref " *
  485.           crossref * warning$
  486.           ""
  487.         }
  488.         { "in {\em " booktitle * "\/}" * " \cite{" * crossref * "}" *}
  489.       if$
  490.     }
  491.     { " {\em in} \citeasnoun{" crossref * "}" * }
  492.       if$
  493.     }
  494.     {  " {\em in} \citeasnoun{" crossref * "}" * }
  495.   if$
  496.  
  497. }
  498.  
  499. INTEGERS { len }
  500.  
  501. FUNCTION {chop.word}
  502. { 's :=
  503.   'len :=
  504.   s #1 len substring$ =
  505.     { s len #1 + global.max$ substring$ }
  506.     's
  507.   if$
  508. }
  509.  
  510. INTEGERS { ind tsslen }
  511.  
  512. STRINGS { tss ret rss istr }
  513.  
  514. FUNCTION {replace.substring}{
  515.   'rss :=
  516.   'tss :=
  517.   'istr :=
  518.   "" 'ret :=
  519.   tss text.length$ 'tsslen :=
  520.   #1 'ind :=
  521.     { istr ind tsslen substring$ "" = not }
  522.     { istr ind tsslen substring$ tss =
  523.         { ret rss * 'ret :=
  524.           ind tsslen + 'ind :=
  525.         }
  526.         { ret istr ind #1 substring$ * 'ret :=
  527.           ind #1 + 'ind :=
  528.         }
  529.       if$
  530.     }
  531.   while$
  532.   ret
  533. }
  534.  
  535. FUNCTION {format.lab.names.abbr}
  536. { 's :=
  537.   s num.names$ 'numnames :=
  538.   numnames #1 >
  539.     { numnames #2 >
  540.     { s #1 "{vv~}{ll}" format.name$ " et~al." * }
  541.     { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  542.             { s #1 "{vv~}{ll}" format.name$ " et~al." * }
  543.         { s #1 "{vv~}{ll}" format.name$ " \harvardand\ " *
  544.               s #2 "{vv~}{ll}" format.name$ * 
  545.             }
  546.           if$
  547.         }
  548.       if$
  549.     }
  550.     { s #1 "{vv~}{ll}" format.name$ }
  551.   if$
  552. }
  553.  
  554. FUNCTION {format.lab.names.full}
  555. { 's :=
  556.   #1 'nameptr :=
  557.   s num.names$ 'numnames :=
  558.   numnames 'namesleft :=
  559.     { namesleft #0 > }
  560.     { s nameptr "{vv~}{ll}" format.name$ 't :=
  561.       nameptr #1 >
  562.     { namesleft #1 >
  563.         { ", " * t * }
  564.         { t "others" =
  565.         { " et~al." * }
  566.         { " \harvardand\ " * t * }
  567.           if$
  568.         }
  569.       if$
  570.     }
  571.     't
  572.       if$
  573.       nameptr #1 + 'nameptr :=
  574.       namesleft #1 - 'namesleft :=
  575.     }
  576.   while$
  577. }
  578.  
  579. INTEGERS { author.field editor.field organization.field title.field key.field }
  580.  
  581. FUNCTION {init.field.constants}
  582. { #0 'author.field :=
  583.   #1 'editor.field :=
  584.   #2 'organization.field :=
  585.   #3 'title.field :=
  586.   #4 'key.field :=
  587. }
  588.  
  589. FUNCTION {make.list.label}
  590. { author.field field.used =
  591.     { format.authors }
  592.     { editor.field field.used =
  593.         { format.editors }
  594.         { organization.field field.used =
  595.             { "The " #4 organization chop.word #3 text.prefix$ }
  596.             { title.field field.used =
  597.                 { format.btitle }
  598.                 { key.field field.used =
  599.                     { key #3 text.prefix$ }
  600.                     { "Internal error :001 on " cite$ * " label" * warning$ }
  601.                   if$
  602.                 }
  603.               if$
  604.             }
  605.           if$
  606.         }
  607.       if$
  608.     }
  609.   if$
  610. }
  611.  
  612. FUNCTION {make.full.label}
  613. { author.field field.used =
  614.     { author format.lab.names.full }
  615.     { editor.field field.used =
  616.         { editor format.lab.names.full }
  617.         { organization.field field.used =
  618.             { "The " #4 organization chop.word #3 text.prefix$ }
  619.             { title.field field.used =
  620.                 { format.btitle }
  621.                 { key.field field.used =
  622.                     { key #3 text.prefix$ }
  623.                     { "Internal error :001 on " cite$ * " label" * warning$ }
  624.                   if$
  625.                 }
  626.               if$
  627.             }
  628.           if$
  629.         }
  630.       if$
  631.     }
  632.   if$
  633. }
  634.  
  635. FUNCTION {make.abbr.label}
  636. { etal.allowed
  637.     { author.field field.used =
  638.         { author format.lab.names.abbr }
  639.         { editor.field field.used =
  640.             { editor format.lab.names.abbr }
  641.             { organization.field field.used =
  642.                 { "The " #4 organization chop.word #3 text.prefix$ }
  643.                 { title.field field.used =
  644.                     { format.btitle }
  645.                     { key.field field.used =
  646.                         { key #3 text.prefix$ }
  647.                         { "Internal error :001 on " cite$ * " label" * warning$}
  648.                       if$
  649.                     }
  650.                   if$
  651.                 }
  652.               if$
  653.             }
  654.           if$
  655.         }
  656.       if$
  657.     }
  658.     { make.full.label }
  659.   if$
  660. }
  661.  
  662. FUNCTION {output.bibitem}
  663. { newline$
  664.   etal.allowed        %%%XXX change
  665.   etal.required
  666.   and
  667.     {
  668.       "\harvarditem[" write$
  669.       make.abbr.label write$
  670.       "]{" write$
  671.     }
  672.     {
  673.       "\harvarditem{" write$
  674.     }
  675.   if$
  676.   make.full.label write$
  677.   "}{" write$
  678.   list.year write$
  679.   "}{" write$
  680.   cite$ write$
  681.   "}" write$
  682.   newline$
  683.   ""
  684.   before.all 'output.state :=
  685. }
  686.  
  687.  
  688. FUNCTION {list.label.output}
  689. { make.list.label " " * write$
  690. }
  691.  
  692. FUNCTION {article}
  693. { output.bibitem
  694.   list.label.output
  695.   " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  696.   new.block
  697.   author "author" item.check
  698.   title.field field.used =
  699.     { skip$ }
  700.     { format.title "title" output.check }
  701.   if$
  702.   crossref missing$
  703.     { journal emphasize "journal" duplicate$ item.check
  704.       " " * format.vol.num.pages * output
  705.     }
  706.     { format.article.crossref output.nonnull
  707.       format.pages output
  708.     }
  709.   if$
  710.   new.block
  711.   note output
  712.   fin.entry
  713.   write.url
  714. }
  715.  
  716. FUNCTION {book}
  717. { output.bibitem
  718.   list.label.output
  719.   " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  720.   new.block
  721.   author empty$
  722.     { editor "author and editor" item.check }
  723.     { crossref missing$
  724.     { "author and editor" editor either.or.check }
  725.     'skip$
  726.       if$
  727.     }
  728.   if$
  729.   title.field field.used =
  730.     { skip$ }
  731.     { format.btitle "title" output.check }
  732.   if$
  733.   crossref missing$
  734.     { format.bvolume output
  735.       format.number.series output
  736.       format.edition output
  737.       publisher "publisher" output.check
  738.       address output
  739.     }
  740.     { format.book.crossref output.nonnull
  741.       format.edition output
  742.     }
  743.   if$
  744.   new.block
  745.   note output
  746.   fin.entry
  747.   write.url
  748. }
  749.  
  750. FUNCTION {booklet}
  751. { output.bibitem
  752.   list.label.output
  753.   " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  754.   new.block
  755.   title.field field.used =
  756.     { skip$ }
  757.     { format.title "title" output.check }
  758.   if$
  759.   howpublished output
  760.   address output
  761.   new.block
  762.   note output
  763.   fin.entry
  764.   write.url
  765. }
  766.  
  767. FUNCTION {inbook}
  768. { output.bibitem
  769.   list.label.output
  770.   " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  771.   new.block
  772.   author empty$
  773.     { editor "author and editor" item.check }
  774.     { crossref missing$
  775.     { "author and editor" editor either.or.check }
  776.     'skip$
  777.       if$
  778.     }
  779.   if$
  780.   title.field field.used =
  781.     { skip$ }
  782.     { format.btitle "title" output.check }
  783.   if$
  784.   crossref missing$
  785.     { format.bvolume output
  786.       format.number.series output
  787.       format.edition output
  788.       publisher "publisher" output.check
  789.       address output
  790.     }
  791.     { format.book.crossref output.nonnull
  792.       format.edition output
  793.     }
  794.   if$
  795.   format.chapter.pages "chapter and pages" output.check
  796.   new.block
  797.   note output
  798.   fin.entry
  799.   write.url
  800. }
  801.  
  802. FUNCTION {incollection}
  803. { output.bibitem
  804.   list.label.output
  805.   " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  806.   new.block
  807.   title.field field.used =
  808.     { skip$ }
  809.     { format.title "title" output.check }
  810.   if$
  811.   author "author" item.check
  812.   crossref missing$
  813.     { format.in.ed.booktitle "booktitle" output.check
  814.       format.edition output
  815.       format.bvolume output
  816.       format.number.series output
  817.       publisher "publisher" output.check
  818.       address output
  819.     }
  820.     { format.incoll.inproc.crossref output.nonnull
  821.     }
  822.   if$
  823.   format.chapter.pages output
  824.   new.block
  825.   note output
  826.   fin.entry
  827.   write.url
  828. }
  829.  
  830. FUNCTION {inproceedings}
  831. { output.bibitem
  832.   list.label.output
  833.   " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  834.   new.block
  835.   title.field field.used =
  836.     { skip$ }
  837.     { format.title "title" output.check }
  838.   if$
  839.   author "author" item.check
  840.   crossref missing$
  841.     { format.in.ed.booktitle "booktitle" output.check
  842.       format.bvolume output
  843.       format.number.series output
  844.       address empty$
  845.     { organization output
  846.       publisher output
  847.     }
  848.     { organization output
  849.       publisher output
  850.       address output.nonnull
  851.     }
  852.       if$
  853.     }
  854.     { format.incoll.inproc.crossref output.nonnull
  855.     }
  856.   if$
  857.   format.pages output
  858.   new.block
  859.   note output
  860.   fin.entry
  861.   write.url
  862. }
  863.  
  864. FUNCTION {conference} { inproceedings }
  865.  
  866. FUNCTION {manual}
  867. { output.bibitem
  868.   list.label.output
  869.   " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  870.   new.block
  871.   title.field field.used =
  872.     { skip$ }
  873.     { format.btitle "title" output.check }
  874.   if$
  875.   format.edition output
  876.   author empty$
  877.     { organization empty$
  878.     { address output
  879.     }
  880.     'skip$
  881.       if$
  882.     }
  883.     { organization output
  884.       address output
  885.     }
  886.   if$
  887.   new.block
  888.   note output
  889.   fin.entry
  890.   write.url
  891. }
  892.  
  893. FUNCTION {mastersthesis}
  894. { output.bibitem
  895.   list.label.output
  896.   " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  897.   new.block
  898.   author "author" item.check
  899.   title.field field.used =
  900.     { skip$ }
  901.     { format.title emphasize "title" output.check }
  902.   if$
  903.   "Master's thesis" format.thesis.type output.nonnull
  904.   school "school" output.check
  905.   address output
  906.   new.block
  907.   note output
  908.   fin.entry
  909.   write.url
  910. }
  911.  
  912. FUNCTION {misc}
  913. { output.bibitem
  914.   list.label.output
  915.   " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  916.   new.block
  917.   title.field field.used =
  918.     { skip$ }
  919.     { format.title output }
  920.   if$
  921.   howpublished output
  922.   new.block
  923.   note output
  924.   fin.entry
  925.   write.url
  926.   empty.misc.check
  927. }
  928.  
  929. FUNCTION {phdthesis}
  930. { output.bibitem
  931.   list.label.output
  932.   " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  933.   new.block
  934.   author "author" item.check
  935.   title.field field.used =
  936.     { skip$ }
  937.     { format.btitle "title" output.check }
  938.   if$
  939.   "PhD thesis" format.thesis.type output.nonnull
  940.   school "school" output.check
  941.   address output
  942.   new.block
  943.   note output
  944.   fin.entry
  945.   write.url
  946. }
  947.  
  948. FUNCTION {proceedings}
  949. { output.bibitem
  950.   list.label.output
  951.   " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  952.   new.block
  953.   title.field field.used =
  954.     { skip$ }
  955.     { format.btitle "title" output.check }
  956.   if$
  957.   format.bvolume output
  958.   format.number.series output
  959.   address empty$
  960.     { editor empty$
  961.     { skip$ }
  962.     { organization output
  963.     }
  964.       if$
  965.       publisher output
  966.     }
  967.     { editor empty$
  968.     'skip$
  969.     { organization output }
  970.       if$
  971.       publisher output
  972.       address output.nonnull
  973.     }
  974.   if$
  975.   new.block
  976.   note output
  977.   fin.entry
  978.   write.url
  979. }
  980.  
  981. FUNCTION {techreport}
  982. { output.bibitem
  983.   list.label.output
  984.   " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  985.   new.block
  986.   author "author" item.check
  987.   title.field field.used =
  988.     { skip$ }
  989.     { format.title "title" output.check }
  990.   if$
  991.   format.tr.number emphasize output.nonnull
  992.   institution "institution" output.check
  993.   address output
  994.   new.block
  995.   note output
  996.   fin.entry
  997.   write.url
  998. }
  999.  
  1000. FUNCTION {unpublished}
  1001. { output.bibitem
  1002.   list.label.output
  1003.   " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  1004.   new.block
  1005.   author "author" item.check
  1006.   title.field field.used =
  1007.     { skip$ }
  1008.     { format.title "title" output.check }
  1009.   if$
  1010.   new.block
  1011.   note "note" output.check
  1012.   fin.entry
  1013.   write.url
  1014. }
  1015.  
  1016. FUNCTION {default.type} { misc }
  1017.  
  1018. MACRO {jan} {"January"}
  1019.  
  1020. MACRO {feb} {"February"}
  1021.  
  1022. MACRO {mar} {"March"}
  1023.  
  1024. MACRO {apr} {"April"}
  1025.  
  1026. MACRO {may} {"May"}
  1027.  
  1028. MACRO {jun} {"June"}
  1029.  
  1030. MACRO {jul} {"July"}
  1031.  
  1032. MACRO {aug} {"August"}
  1033.  
  1034. MACRO {sep} {"September"}
  1035.  
  1036. MACRO {oct} {"October"}
  1037.  
  1038. MACRO {nov} {"November"}
  1039.  
  1040. MACRO {dec} {"December"}
  1041.  
  1042. MACRO {acmcs} {"ACM Computing Surveys"}
  1043.  
  1044. MACRO {acta} {"Acta Informatica"}
  1045.  
  1046. MACRO {cacm} {"Communications of the ACM"}
  1047.  
  1048. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  1049.  
  1050. MACRO {ibmsj} {"IBM Systems Journal"}
  1051.  
  1052. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  1053.  
  1054. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  1055.  
  1056. MACRO {ieeetcad}
  1057.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  1058.  
  1059. MACRO {ipl} {"Information Processing Letters"}
  1060.  
  1061. MACRO {jacm} {"Journal of the ACM"}
  1062.  
  1063. MACRO {jcss} {"Journal of Computer and System Sciences"}
  1064.  
  1065. MACRO {scp} {"Science of Computer Programming"}
  1066.  
  1067. MACRO {sicomp} {"SIAM Journal on Computing"}
  1068.  
  1069. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  1070.  
  1071. MACRO {tods} {"ACM Transactions on Database Systems"}
  1072.  
  1073. MACRO {tog} {"ACM Transactions on Graphics"}
  1074.  
  1075. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  1076.  
  1077. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  1078.  
  1079. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  1080.  
  1081. MACRO {tcs} {"Theoretical Computer Science"}
  1082.  
  1083. READ
  1084.  
  1085. EXECUTE {init.field.constants}
  1086.  
  1087. FUNCTION {sortify}
  1088. { purify$
  1089.   "l" change.case$
  1090. }
  1091.  
  1092. FUNCTION {sortify.names}
  1093. { " \harvardand\ " " " replace.substring
  1094.   " et~al." " zzz" replace.substring
  1095.   sortify
  1096. }
  1097.  
  1098. FUNCTION {author.key.label}
  1099. { author empty$
  1100.     { key empty$
  1101.     { title.field 'field.used := }
  1102.     { key.field 'field.used := }
  1103.       if$
  1104.     }
  1105.     { author.field 'field.used := }
  1106.   if$
  1107. }
  1108.  
  1109. FUNCTION {author.editor.key.label}
  1110. { author empty$
  1111.     { editor empty$
  1112.     { key empty$
  1113.         { title.field 'field.used := }
  1114.         { key.field 'field.used := }
  1115.       if$
  1116.       }
  1117.     { editor.field 'field.used := }
  1118.       if$
  1119.     }
  1120.     { author.field 'field.used := }
  1121.   if$
  1122. }
  1123.  
  1124. FUNCTION {author.key.organization.label}
  1125. { author empty$
  1126.     { key empty$
  1127.     { organization empty$
  1128.         { title.field 'field.used := }
  1129.         { organization.field 'field.used := }
  1130.       if$
  1131.     }
  1132.     { key.field 'field.used := }
  1133.       if$
  1134.     }
  1135.     { author.field 'field.used := }
  1136.   if$
  1137. }
  1138.  
  1139. FUNCTION {editor.key.organization.label}
  1140. { editor empty$
  1141.     { key empty$
  1142.     { organization empty$
  1143.         { title.field 'field.used := }
  1144.         { organization.field 'field.used := }
  1145.       if$
  1146.     }
  1147.     { key.field 'field.used := }
  1148.       if$
  1149.     }
  1150.     { editor.field 'field.used := }
  1151.   if$
  1152. }
  1153.  
  1154. FUNCTION {sort.format.title}
  1155. { 't :=
  1156.   "A " #2
  1157.     "An " #3
  1158.       "The " #4 t chop.word
  1159.     chop.word
  1160.   chop.word
  1161.   sortify
  1162.   #1 global.max$ substring$
  1163. }
  1164.  
  1165. FUNCTION {calc.label}
  1166. { make.abbr.label
  1167.   title.field field.used =
  1168.     { sort.format.title }
  1169.     { sortify.names }
  1170.   if$
  1171.   year field.or.null purify$ #-1 #4 substring$ sortify
  1172.   *
  1173.   'sort.label :=
  1174. }
  1175.  
  1176. FUNCTION {preliminaries} %%%XXX change
  1177. { type$ "book" =
  1178.   type$ "inbook" =
  1179.   or
  1180.     'author.editor.key.label
  1181.     { type$ "proceedings" =
  1182.     'editor.key.organization.label
  1183.     { type$ "manual" =
  1184.         'author.key.organization.label
  1185.         'author.key.label
  1186.       if$
  1187.     }
  1188.       if$
  1189.     }
  1190.   if$
  1191.   author.field field.used = %%%XXX change
  1192.     {
  1193.       author num.names$ #2 >
  1194.         { #1 }
  1195.         { #0 }
  1196.       if$
  1197.       'etal.required :=
  1198.     }
  1199.     {
  1200.       editor.field field.used = 
  1201.         {
  1202.           editor num.names$ #2 >
  1203.             { #1 }
  1204.             { #0 }
  1205.           if$
  1206.         }
  1207.         { #0 }
  1208.       if$
  1209.       'etal.required :=
  1210.     }
  1211.   if$
  1212.   #1 'etal.allowed :=
  1213. }
  1214.  
  1215. FUNCTION {first.presort}
  1216. { calc.label
  1217.   sort.label
  1218.   title.field field.used =
  1219.     { skip$ }
  1220.     { "    "
  1221.       *
  1222.       make.list.label sortify.names
  1223.       *
  1224.       "    "
  1225.       *
  1226.       title field.or.null
  1227.       sort.format.title
  1228.       *
  1229.     }
  1230.   if$
  1231.   #1 entry.max$ substring$
  1232.   'sort.key$ :=
  1233. }
  1234.  
  1235. ITERATE {preliminaries}
  1236.  
  1237. ITERATE {first.presort}
  1238.  
  1239. SORT
  1240.  
  1241. STRINGS { last.sort.label next.extra last.full.label }
  1242.  
  1243. INTEGERS { last.extra.num last.etal.allowed }
  1244.  
  1245. FUNCTION {initialize.confusion}
  1246. { #0 int.to.chr$ 'last.sort.label :=
  1247.   #0 int.to.chr$ 'last.full.label :=
  1248.   #1 'last.etal.allowed :=
  1249. }
  1250.  
  1251. FUNCTION {confusion.pass}
  1252. { last.sort.label sort.label =
  1253.     { last.etal.allowed 
  1254.         { last.full.label make.full.label sortify.names =
  1255.             { skip$ }
  1256.             { #0 'etal.allowed :=
  1257.               #0 'last.etal.allowed :=
  1258.             }
  1259.           if$
  1260.         }
  1261.         { #0 'etal.allowed := }
  1262.       if$
  1263.     }
  1264.     { sort.label 'last.sort.label :=
  1265.       make.full.label sortify.names 'last.full.label :=
  1266.       #1 'last.etal.allowed :=
  1267.     }
  1268.   if$
  1269. }
  1270.  
  1271. EXECUTE {initialize.confusion}
  1272.  
  1273. ITERATE {confusion.pass}
  1274.  
  1275. EXECUTE {initialize.confusion}
  1276.  
  1277. REVERSE {confusion.pass}
  1278.  
  1279. FUNCTION {initialize.last.extra.num}
  1280. { #0 int.to.chr$ 'last.sort.label :=
  1281.   "" 'next.extra :=
  1282.   #0 'last.extra.num :=
  1283. }
  1284.  
  1285. FUNCTION {forward.pass}
  1286. { last.sort.label sort.label =
  1287.     { last.extra.num #1 + 'last.extra.num :=
  1288.       last.extra.num int.to.chr$ 'extra.label :=
  1289.     }
  1290.     { "a" chr.to.int$ 'last.extra.num :=
  1291.       "" 'extra.label :=
  1292.       sort.label 'last.sort.label :=
  1293.     }
  1294.   if$
  1295. }
  1296.  
  1297. FUNCTION {reverse.pass}
  1298. { next.extra "b" =
  1299.     { "a" 'extra.label := }
  1300.     'skip$
  1301.   if$
  1302.   year empty$
  1303.     { "n.d." extra.label * 'list.year := }
  1304.     { year extra.label * 'list.year := }
  1305.   if$
  1306.   extra.label 'next.extra :=
  1307. }
  1308.  
  1309. ITERATE {first.presort}
  1310.  
  1311. SORT
  1312.  
  1313. EXECUTE {initialize.last.extra.num}
  1314.  
  1315. ITERATE {forward.pass}
  1316.  
  1317. REVERSE {reverse.pass}
  1318.  
  1319. FUNCTION {second.presort}
  1320. { make.list.label
  1321.   title.field field.used =
  1322.     { sort.format.title }
  1323.     { sortify.names }
  1324.   if$
  1325.   "    "
  1326.   *
  1327.   list.year field.or.null sortify
  1328.   *
  1329.   "    "
  1330.   *
  1331.   title.field field.used =
  1332.     { skip$ }
  1333.     { title field.or.null
  1334.       sort.format.title
  1335.       *
  1336.     }
  1337.   if$
  1338.   #1 entry.max$ substring$
  1339.   'sort.key$ :=
  1340. }
  1341.  
  1342. ITERATE {second.presort}
  1343.  
  1344. SORT
  1345.  
  1346. FUNCTION {begin.bib}
  1347. { preamble$ empty$
  1348.     'skip$
  1349.     { preamble$ write$ newline$ }
  1350.   if$
  1351.   "\begin{thebibliography}{xx}" write$ newline$
  1352. }
  1353.  
  1354. EXECUTE {begin.bib}
  1355.  
  1356. EXECUTE {init.state.consts}
  1357.  
  1358. ITERATE {call.type$}
  1359.  
  1360. FUNCTION {end.bib}
  1361. { newline$
  1362.   "\end{thebibliography}" write$ newline$
  1363. }
  1364.  
  1365. EXECUTE {end.bib}
  1366.